.class public Lcom/melesta/payment/PaymentManager;
.super Ljava/lang/Object;
.source "PaymentManager.java"

# interfaces
.implements Lcom/melesta/payment/interfaces/IActivityStateListener;


# static fields
.field private static inst:Lcom/melesta/payment/PaymentManager;


# instance fields
.field private final activeRequests:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List",
            "<",
            "Lcom/melesta/payment/interfaces/IRequest;",
            ">;"
        }
    .end annotation
.end field

.field private handler:Landroid/os/Handler;

.field private final requests:Ljava/util/Queue;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Queue",
            "<",
            "Lcom/melesta/payment/interfaces/IRequest;",
            ">;"
        }
    .end annotation
.end field

.field private final requestsList:Ljava/util/Map;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Map",
            "<",
            "Ljava/lang/String;",
            "Lcom/melesta/payment/interfaces/IRequest;",
            ">;"
        }
    .end annotation
.end field

.field private final responses:Ljava/util/Queue;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Queue",
            "<",
            "Lcom/melesta/payment/interfaces/IResponse;",
            ">;"
        }
    .end annotation
.end field

.field private final systemsList:Ljava/util/Map;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Map",
            "<",
            "Ljava/lang/String;",
            "Lcom/melesta/payment/interfaces/ISystem;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method private constructor <init>()V
    .locals 1

    .prologue
    .line 68
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 69
    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    iput-object v0, p0, Lcom/melesta/payment/PaymentManager;->activeRequests:Ljava/util/List;

    .line 70
    new-instance v0, Ljava/util/LinkedList;

    invoke-direct {v0}, Ljava/util/LinkedList;-><init>()V

    iput-object v0, p0, Lcom/melesta/payment/PaymentManager;->requests:Ljava/util/Queue;

    .line 71
    new-instance v0, Ljava/util/LinkedList;

    invoke-direct {v0}, Ljava/util/LinkedList;-><init>()V

    iput-object v0, p0, Lcom/melesta/payment/PaymentManager;->responses:Ljava/util/Queue;

    .line 72
    new-instance v0, Ljava/util/HashMap;

    invoke-direct {v0}, Ljava/util/HashMap;-><init>()V

    iput-object v0, p0, Lcom/melesta/payment/PaymentManager;->requestsList:Ljava/util/Map;

    .line 73
    new-instance v0, Ljava/util/HashMap;

    invoke-direct {v0}, Ljava/util/HashMap;-><init>()V

    iput-object v0, p0, Lcom/melesta/payment/PaymentManager;->systemsList:Ljava/util/Map;

    .line 74
    return-void
.end method

.method private addRequest(Lcom/melesta/payment/interfaces/IRequest;)V
    .locals 2
    .parameter "request"

    .prologue
    .line 199
    iget-object v0, p0, Lcom/melesta/payment/PaymentManager;->requestsList:Ljava/util/Map;

    invoke-interface {p1}, Lcom/melesta/payment/interfaces/IRequest;->getName()Ljava/lang/String;

    move-result-object v1

    invoke-interface {v0, v1, p1}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 200
    return-void
.end method

.method public static getInstance()Lcom/melesta/payment/PaymentManager;
    .locals 1

    .prologue
    .line 39
    sget-object v0, Lcom/melesta/payment/PaymentManager;->inst:Lcom/melesta/payment/PaymentManager;

    if-nez v0, :cond_0

    .line 40
    new-instance v0, Lcom/melesta/payment/PaymentManager;

    invoke-direct {v0}, Lcom/melesta/payment/PaymentManager;-><init>()V

    sput-object v0, Lcom/melesta/payment/PaymentManager;->inst:Lcom/melesta/payment/PaymentManager;

    .line 41
    :cond_0
    sget-object v0, Lcom/melesta/payment/PaymentManager;->inst:Lcom/melesta/payment/PaymentManager;

    return-object v0
.end method

.method private loadPayments(Lorg/w3c/dom/Node;)V
    .locals 13
    .parameter "node"

    .prologue
    .line 207
    invoke-interface {p1}, Lorg/w3c/dom/Node;->getChildNodes()Lorg/w3c/dom/NodeList;

    move-result-object v5

    .line 208
    .local v5, items:Lorg/w3c/dom/NodeList;
    const/4 v3, 0x0

    .local v3, i:I
    :goto_0
    invoke-interface {v5}, Lorg/w3c/dom/NodeList;->getLength()I

    move-result v11

    if-ge v3, v11, :cond_3

    .line 209
    invoke-interface {v5, v3}, Lorg/w3c/dom/NodeList;->item(I)Lorg/w3c/dom/Node;

    move-result-object v4

    .line 210
    .local v4, item:Lorg/w3c/dom/Node;
    invoke-interface {v4}, Lorg/w3c/dom/Node;->getAttributes()Lorg/w3c/dom/NamedNodeMap;

    move-result-object v1

    .line 211
    .local v1, attrs:Lorg/w3c/dom/NamedNodeMap;
    if-nez v1, :cond_1

    .line 208
    :cond_0
    :goto_1
    add-int/lit8 v3, v3, 0x1

    goto :goto_0

    .line 213
    :cond_1
    const-string v11, "name"

    invoke-interface {v1, v11}, Lorg/w3c/dom/NamedNodeMap;->getNamedItem(Ljava/lang/String;)Lorg/w3c/dom/Node;

    move-result-object v8

    .line 214
    .local v8, nname:Lorg/w3c/dom/Node;
    if-eqz v8, :cond_0

    .line 216
    invoke-interface {v8}, Lorg/w3c/dom/Node;->getNodeValue()Ljava/lang/String;

    move-result-object v7

    .line 217
    .local v7, name:Ljava/lang/String;
    invoke-interface {v4}, Lorg/w3c/dom/Node;->getNodeName()Ljava/lang/String;

    move-result-object v10

    .line 218
    .local v10, type:Ljava/lang/String;
    if-eqz v7, :cond_0

    invoke-virtual {v7}, Ljava/lang/String;->length()I

    move-result v11

    if-eqz v11, :cond_0

    if-eqz v10, :cond_0

    invoke-virtual {v10}, Ljava/lang/String;->length()I

    move-result v11

    if-eqz v11, :cond_0

    .line 221
    invoke-virtual {p0, v10}, Lcom/melesta/payment/PaymentManager;->getSystem(Ljava/lang/String;)Lcom/melesta/payment/interfaces/ISystem;

    move-result-object v9

    .line 222
    .local v9, system:Lcom/melesta/payment/interfaces/ISystem;
    if-eqz v9, :cond_0

    .line 224
    invoke-interface {v9}, Lcom/melesta/payment/interfaces/ISystem;->getRequestBuilder()Lcom/melesta/payment/interfaces/IRequestBuilder;

    move-result-object v2

    .line 225
    .local v2, builder:Lcom/melesta/payment/interfaces/IRequestBuilder;
    if-eqz v2, :cond_0

    .line 227
    const/4 v6, 0x0

    .local v6, j:I
    :goto_2
    invoke-interface {v1}, Lorg/w3c/dom/NamedNodeMap;->getLength()I

    move-result v11

    if-ge v6, v11, :cond_2

    .line 228
    invoke-interface {v1, v6}, Lorg/w3c/dom/NamedNodeMap;->item(I)Lorg/w3c/dom/Node;

    move-result-object v0

    .line 229
    .local v0, attr:Lorg/w3c/dom/Node;
    invoke-interface {v0}, Lorg/w3c/dom/Node;->getNodeName()Ljava/lang/String;

    move-result-object v11

    invoke-interface {v0}, Lorg/w3c/dom/Node;->getNodeValue()Ljava/lang/String;

    move-result-object v12

    invoke-interface {v2, v11, v12}, Lcom/melesta/payment/interfaces/IRequestBuilder;->set(Ljava/lang/String;Ljava/lang/Object;)Lcom/melesta/payment/interfaces/IRequestBuilder;

    .line 227
    add-int/lit8 v6, v6, 0x1

    goto :goto_2

    .line 231
    .end local v0           #attr:Lorg/w3c/dom/Node;
    :cond_2
    invoke-interface {v2}, Lcom/melesta/payment/interfaces/IRequestBuilder;->createRequest()Lcom/melesta/payment/interfaces/IRequest;

    move-result-object v11

    invoke-direct {p0, v11}, Lcom/melesta/payment/PaymentManager;->addRequest(Lcom/melesta/payment/interfaces/IRequest;)V

    goto :goto_1

    .line 233
    .end local v1           #attrs:Lorg/w3c/dom/NamedNodeMap;
    .end local v2           #builder:Lcom/melesta/payment/interfaces/IRequestBuilder;
    .end local v4           #item:Lorg/w3c/dom/Node;
    .end local v6           #j:I
    .end local v7           #name:Ljava/lang/String;
    .end local v8           #nname:Lorg/w3c/dom/Node;
    .end local v9           #system:Lcom/melesta/payment/interfaces/ISystem;
    .end local v10           #type:Ljava/lang/String;
    :cond_3
    return-void
.end method

.method private loadSystems(Lorg/w3c/dom/Node;)V
    .locals 10
    .parameter "node"

    .prologue
    .line 236
    invoke-interface {p1}, Lorg/w3c/dom/Node;->getChildNodes()Lorg/w3c/dom/NodeList;

    move-result-object v4

    .line 237
    .local v4, items:Lorg/w3c/dom/NodeList;
    const/4 v2, 0x0

    .local v2, i:I
    :goto_0
    invoke-interface {v4}, Lorg/w3c/dom/NodeList;->getLength()I

    move-result v8

    if-ge v2, v8, :cond_2

    .line 238
    invoke-interface {v4, v2}, Lorg/w3c/dom/NodeList;->item(I)Lorg/w3c/dom/Node;

    move-result-object v3

    .line 239
    .local v3, item:Lorg/w3c/dom/Node;
    invoke-interface {v3}, Lorg/w3c/dom/Node;->getAttributes()Lorg/w3c/dom/NamedNodeMap;

    move-result-object v1

    .line 240
    .local v1, attrs:Lorg/w3c/dom/NamedNodeMap;
    if-nez v1, :cond_1

    .line 237
    :cond_0
    add-int/lit8 v2, v2, 0x1

    goto :goto_0

    .line 242
    :cond_1
    invoke-interface {v3}, Lorg/w3c/dom/Node;->getNodeName()Ljava/lang/String;

    move-result-object v7

    .line 243
    .local v7, type:Ljava/lang/String;
    if-eqz v7, :cond_0

    invoke-virtual {v7}, Ljava/lang/String;->length()I

    move-result v8

    if-eqz v8, :cond_0

    .line 245
    invoke-virtual {p0, v7}, Lcom/melesta/payment/PaymentManager;->getSystem(Ljava/lang/String;)Lcom/melesta/payment/interfaces/ISystem;

    move-result-object v6

    .line 246
    .local v6, system:Lcom/melesta/payment/interfaces/ISystem;
    if-eqz v6, :cond_0

    .line 248
    const/4 v5, 0x0

    .local v5, j:I
    :goto_1
    invoke-interface {v1}, Lorg/w3c/dom/NamedNodeMap;->getLength()I

    move-result v8

    if-ge v5, v8, :cond_0

    .line 249
    invoke-interface {v1, v5}, Lorg/w3c/dom/NamedNodeMap;->item(I)Lorg/w3c/dom/Node;

    move-result-object v0

    .line 250
    .local v0, attr:Lorg/w3c/dom/Node;
    invoke-interface {v0}, Lorg/w3c/dom/Node;->getNodeName()Ljava/lang/String;

    move-result-object v8

    invoke-interface {v0}, Lorg/w3c/dom/Node;->getNodeValue()Ljava/lang/String;

    move-result-object v9

    invoke-interface {v6, v8, v9}, Lcom/melesta/payment/interfaces/ISystem;->set(Ljava/lang/String;Ljava/lang/Object;)Lcom/melesta/payment/interfaces/ISystem;

    .line 248
    add-int/lit8 v5, v5, 0x1

    goto :goto_1

    .line 253
    .end local v0           #attr:Lorg/w3c/dom/Node;
    .end local v1           #attrs:Lorg/w3c/dom/NamedNodeMap;
    .end local v3           #item:Lorg/w3c/dom/Node;
    .end local v5           #j:I
    .end local v6           #system:Lcom/melesta/payment/interfaces/ISystem;
    .end local v7           #type:Ljava/lang/String;
    :cond_2
    return-void
.end method

.method private postRequest(Lcom/melesta/payment/interfaces/IRequest;)V
    .locals 3
    .parameter "request"

    .prologue
    .line 256
    const-string v0, "payment"

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "Post request: "

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-static {v0, v1}, Lcom/melesta/engine/Log;->d(Ljava/lang/String;Ljava/lang/String;)V

    .line 257
    if-nez p1, :cond_0

    .line 262
    :goto_0
    return-void

    .line 259
    :cond_0
    iget-object v1, p0, Lcom/melesta/payment/PaymentManager;->requests:Ljava/util/Queue;

    monitor-enter v1

    .line 260
    :try_start_0
    iget-object v0, p0, Lcom/melesta/payment/PaymentManager;->requests:Ljava/util/Queue;

    invoke-interface {v0, p1}, Ljava/util/Queue;->add(Ljava/lang/Object;)Z

    .line 261
    monitor-exit v1

    goto :goto_0

    :catchall_0
    move-exception v0

    monitor-exit v1
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v0
.end method

.method public static tryBuy(Ljava/lang/String;F)V
    .locals 8
    .parameter "name"
    .parameter "multiplier"

    .prologue
    .line 45
    const-string v4, "payment"

    new-instance v5, Ljava/lang/StringBuilder;

    invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V

    const-string v6, "Try buy: "

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-static {v4, v5}, Lcom/melesta/engine/Log;->d(Ljava/lang/String;Ljava/lang/String;)V

    .line 47
    :try_start_0
    invoke-static {}, Lcom/melesta/payment/PaymentManager;->getInstance()Lcom/melesta/payment/PaymentManager;

    move-result-object v1

    .line 48
    .local v1, me:Lcom/melesta/payment/PaymentManager;
    invoke-virtual {v1, p0}, Lcom/melesta/payment/PaymentManager;->getRequest(Ljava/lang/String;)Lcom/melesta/payment/interfaces/IRequest;

    move-result-object v2

    .line 49
    .local v2, request:Lcom/melesta/payment/interfaces/IRequest;
    invoke-interface {v2, p1}, Lcom/melesta/payment/interfaces/IRequest;->setMultiplier(F)Lcom/melesta/payment/interfaces/IRequest;

    move-result-object v3

    .line 50
    .local v3, request2:Lcom/melesta/payment/interfaces/IRequest;
    invoke-direct {v1, v3}, Lcom/melesta/payment/PaymentManager;->postRequest(Lcom/melesta/payment/interfaces/IRequest;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 55
    .end local v1           #me:Lcom/melesta/payment/PaymentManager;
    .end local v2           #request:Lcom/melesta/payment/interfaces/IRequest;
    .end local v3           #request2:Lcom/melesta/payment/interfaces/IRequest;
    :goto_0
    return-void

    .line 52
    :catch_0
    move-exception v0

    .line 53
    .local v0, ex:Ljava/lang/Exception;
    const-string v4, "tryBuy (%s, %f)"

    const/4 v5, 0x2

    new-array v5, v5, [Ljava/lang/Object;

    const/4 v6, 0x0

    aput-object p0, v5, v6

    const/4 v6, 0x1

    invoke-static {p1}, Ljava/lang/Float;->valueOf(F)Ljava/lang/Float;

    move-result-object v7

    aput-object v7, v5, v6

    invoke-static {v4, v5}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v4

    invoke-static {v4, v0}, Lcom/melesta/engine/Error;->processException(Ljava/lang/String;Ljava/lang/Exception;)V

    goto :goto_0
.end method

.method public static tryProcess()V
    .locals 1

    .prologue
    .line 58
    invoke-static {}, Lcom/melesta/payment/PaymentManager;->getInstance()Lcom/melesta/payment/PaymentManager;

    move-result-object v0

    invoke-virtual {v0}, Lcom/melesta/payment/PaymentManager;->process()V

    .line 59
    return-void
.end method


# virtual methods
.method public addSystem(Lcom/melesta/payment/interfaces/ISystem;)V
    .locals 2
    .parameter "system"

    .prologue
    .line 77
    iget-object v0, p0, Lcom/melesta/payment/PaymentManager;->systemsList:Ljava/util/Map;

    invoke-interface {p1}, Lcom/melesta/payment/interfaces/ISystem;->getName()Ljava/lang/String;

    move-result-object v1

    invoke-interface {v0, v1, p1}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 78
    return-void
.end method

.method public getActiveRequest(Lcom/melesta/payment/interfaces/IRequestFilter;)Lcom/melesta/payment/interfaces/IRequest;
    .locals 3
    .parameter "filter"

    .prologue
    .line 100
    iget-object v2, p0, Lcom/melesta/payment/PaymentManager;->activeRequests:Ljava/util/List;

    invoke-interface {v2}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v0

    .local v0, i$:Ljava/util/Iterator;
    :cond_0
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v2

    if-eqz v2, :cond_1

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/melesta/payment/interfaces/IRequest;

    .line 101
    .local v1, request:Lcom/melesta/payment/interfaces/IRequest;
    invoke-interface {p1, v1}, Lcom/melesta/payment/interfaces/IRequestFilter;->accept(Lcom/melesta/payment/interfaces/IRequest;)Z

    move-result v2

    if-eqz v2, :cond_0

    .line 105
    .end local v1           #request:Lcom/melesta/payment/interfaces/IRequest;
    :goto_0
    return-object v1

    :cond_1
    const/4 v1, 0x0

    goto :goto_0
.end method

.method public getAllRequests(Ljava/lang/String;)Ljava/util/List;
    .locals 4
    .parameter "systemName"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/String;",
            ")",
            "Ljava/util/List",
            "<",
            "Lcom/melesta/payment/interfaces/IRequest;",
            ">;"
        }
    .end annotation

    .prologue
    .line 90
    new-instance v2, Ljava/util/ArrayList;

    invoke-direct {v2}, Ljava/util/ArrayList;-><init>()V

    .line 91
    .local v2, res:Ljava/util/List;,"Ljava/util/List<Lcom/melesta/payment/interfaces/IRequest;>;"
    iget-object v3, p0, Lcom/melesta/payment/PaymentManager;->requestsList:Ljava/util/Map;

    invoke-interface {v3}, Ljava/util/Map;->values()Ljava/util/Collection;

    move-result-object v3

    invoke-interface {v3}, Ljava/util/Collection;->iterator()Ljava/util/Iterator;

    move-result-object v0

    .local v0, i$:Ljava/util/Iterator;
    :cond_0
    :goto_0
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v3

    if-eqz v3, :cond_1

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/melesta/payment/interfaces/IRequest;

    .line 92
    .local v1, r:Lcom/melesta/payment/interfaces/IRequest;
    invoke-interface {v1}, Lcom/melesta/payment/interfaces/IRequest;->getPaymentSystemName()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v3, p1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v3

    if-eqz v3, :cond_0

    .line 93
    invoke-interface {v2, v1}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    goto :goto_0

    .line 95
    .end local v1           #r:Lcom/melesta/payment/interfaces/IRequest;
    :cond_1
    return-object v2
.end method

.method public getRequest(Lcom/melesta/payment/interfaces/IRequestFilter;)Lcom/melesta/payment/interfaces/IRequest;
    .locals 3
    .parameter "filter"

    .prologue
    .line 81
    iget-object v2, p0, Lcom/melesta/payment/PaymentManager;->requestsList:Ljava/util/Map;

    invoke-interface {v2}, Ljava/util/Map;->values()Ljava/util/Collection;

    move-result-object v2

    invoke-interface {v2}, Ljava/util/Collection;->iterator()Ljava/util/Iterator;

    move-result-object v0

    .local v0, i$:Ljava/util/Iterator;
    :cond_0
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v2

    if-eqz v2, :cond_1

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/melesta/payment/interfaces/IRequest;

    .line 82
    .local v1, request:Lcom/melesta/payment/interfaces/IRequest;
    invoke-interface {p1, v1}, Lcom/melesta/payment/interfaces/IRequestFilter;->accept(Lcom/melesta/payment/interfaces/IRequest;)Z

    move-result v2

    if-eqz v2, :cond_0

    .line 85
    .end local v1           #request:Lcom/melesta/payment/interfaces/IRequest;
    :goto_0
    return-object v1

    :cond_1
    const/4 v1, 0x0

    goto :goto_0
.end method

.method public getRequest(Ljava/lang/String;)Lcom/melesta/payment/interfaces/IRequest;
    .locals 1
    .parameter "name"

    .prologue
    .line 115
    iget-object v0, p0, Lcom/melesta/payment/PaymentManager;->requestsList:Ljava/util/Map;

    invoke-interface {v0, p1}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/melesta/payment/interfaces/IRequest;

    return-object v0
.end method

.method public getRequestNameBySku(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    .locals 3
    .parameter "systemName"
    .parameter "sku"

    .prologue
    .line 282
    iget-object v2, p0, Lcom/melesta/payment/PaymentManager;->requestsList:Ljava/util/Map;

    invoke-interface {v2}, Ljava/util/Map;->values()Ljava/util/Collection;

    move-result-object v2

    invoke-interface {v2}, Ljava/util/Collection;->iterator()Ljava/util/Iterator;

    move-result-object v0

    .local v0, i$:Ljava/util/Iterator;
    :cond_0
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v2

    if-eqz v2, :cond_1

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/melesta/payment/interfaces/IRequest;

    .line 283
    .local v1, request:Lcom/melesta/payment/interfaces/IRequest;
    invoke-interface {v1}, Lcom/melesta/payment/interfaces/IRequest;->getSku()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v2, p2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-eqz v2, :cond_0

    invoke-interface {v1}, Lcom/melesta/payment/interfaces/IRequest;->getPaymentSystemName()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v2, p1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-eqz v2, :cond_0

    .line 284
    invoke-interface {v1}, Lcom/melesta/payment/interfaces/IRequest;->getName()Ljava/lang/String;

    move-result-object v2

    .line 286
    .end local v1           #request:Lcom/melesta/payment/interfaces/IRequest;
    :goto_0
    return-object v2

    :cond_1
    const/4 v2, 0x0

    goto :goto_0
.end method

.method public getSystem(Ljava/lang/String;)Lcom/melesta/payment/interfaces/ISystem;
    .locals 1
    .parameter "name"

    .prologue
    .line 203
    iget-object v0, p0, Lcom/melesta/payment/PaymentManager;->systemsList:Ljava/util/Map;

    invoke-interface {v0, p1}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/melesta/payment/interfaces/ISystem;

    return-object v0
.end method

.method public load(Ljava/io/InputStream;)V
    .locals 10
    .parameter "xml_stream"

    .prologue
    .line 119
    invoke-static {}, Ljavax/xml/parsers/DocumentBuilderFactory;->newInstance()Ljavax/xml/parsers/DocumentBuilderFactory;

    move-result-object v3

    .line 121
    .local v3, factory:Ljavax/xml/parsers/DocumentBuilderFactory;
    :try_start_0
    invoke-virtual {v3}, Ljavax/xml/parsers/DocumentBuilderFactory;->newDocumentBuilder()Ljavax/xml/parsers/DocumentBuilder;

    move-result-object v0

    .line 122
    .local v0, doc:Ljavax/xml/parsers/DocumentBuilder;
    invoke-virtual {v0, p1}, Ljavax/xml/parsers/DocumentBuilder;->parse(Ljava/io/InputStream;)Lorg/w3c/dom/Document;

    move-result-object v1

    .line 123
    .local v1, dom:Lorg/w3c/dom/Document;
    invoke-interface {v1}, Lorg/w3c/dom/Document;->getDocumentElement()Lorg/w3c/dom/Element;

    move-result-object v7

    .line 124
    .local v7, root:Lorg/w3c/dom/Element;
    invoke-interface {v7}, Lorg/w3c/dom/Element;->getChildNodes()Lorg/w3c/dom/NodeList;

    move-result-object v6

    .line 125
    .local v6, items:Lorg/w3c/dom/NodeList;
    const/4 v4, 0x0

    .local v4, i:I
    :goto_0
    invoke-interface {v6}, Lorg/w3c/dom/NodeList;->getLength()I

    move-result v8

    if-ge v4, v8, :cond_2

    .line 126
    invoke-interface {v6, v4}, Lorg/w3c/dom/NodeList;->item(I)Lorg/w3c/dom/Node;

    move-result-object v5

    .line 127
    .local v5, item:Lorg/w3c/dom/Node;
    invoke-interface {v5}, Lorg/w3c/dom/Node;->getNodeName()Ljava/lang/String;

    move-result-object v8

    const-string v9, "payments"

    invoke-virtual {v8, v9}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v8

    if-eqz v8, :cond_1

    .line 128
    invoke-direct {p0, v5}, Lcom/melesta/payment/PaymentManager;->loadPayments(Lorg/w3c/dom/Node;)V

    .line 125
    :cond_0
    :goto_1
    add-int/lit8 v4, v4, 0x1

    goto :goto_0

    .line 129
    :cond_1
    invoke-interface {v5}, Lorg/w3c/dom/Node;->getNodeName()Ljava/lang/String;

    move-result-object v8

    const-string v9, "systems"

    invoke-virtual {v8, v9}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v8

    if-eqz v8, :cond_0

    .line 130
    invoke-direct {p0, v5}, Lcom/melesta/payment/PaymentManager;->loadSystems(Lorg/w3c/dom/Node;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_1

    .line 132
    .end local v0           #doc:Ljavax/xml/parsers/DocumentBuilder;
    .end local v1           #dom:Lorg/w3c/dom/Document;
    .end local v4           #i:I
    .end local v5           #item:Lorg/w3c/dom/Node;
    .end local v6           #items:Lorg/w3c/dom/NodeList;
    .end local v7           #root:Lorg/w3c/dom/Element;
    :catch_0
    move-exception v2

    .line 133
    .local v2, e:Ljava/lang/Exception;
    const/4 v8, 0x0

    invoke-static {v8, v2}, Lcom/melesta/engine/Error;->processException(Ljava/lang/String;Ljava/lang/Exception;)V

    .line 135
    .end local v2           #e:Ljava/lang/Exception;
    :cond_2
    return-void
.end method

.method public onActivityResult(Landroid/content/Context;IILandroid/content/Intent;)Z
    .locals 4
    .parameter "context"
    .parameter "requestCode"
    .parameter "resultCode"
    .parameter "data"

    .prologue
    .line 266
    const/4 v1, 0x0

    .line 267
    .local v1, res:Z
    iget-object v3, p0, Lcom/melesta/payment/PaymentManager;->systemsList:Ljava/util/Map;

    invoke-interface {v3}, Ljava/util/Map;->values()Ljava/util/Collection;

    move-result-object v3

    invoke-interface {v3}, Ljava/util/Collection;->iterator()Ljava/util/Iterator;

    move-result-object v0

    .local v0, i$:Ljava/util/Iterator;
    :goto_0
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v3

    if-eqz v3, :cond_0

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Lcom/melesta/payment/interfaces/ISystem;

    .line 268
    .local v2, sys:Lcom/melesta/payment/interfaces/ISystem;
    invoke-interface {v2, p1, p2, p3, p4}, Lcom/melesta/payment/interfaces/ISystem;->onActivityResult(Landroid/content/Context;IILandroid/content/Intent;)Z

    move-result v3

    or-int/2addr v1, v3

    .line 269
    goto :goto_0

    .line 271
    .end local v2           #sys:Lcom/melesta/payment/interfaces/ISystem;
    :cond_0
    return v1
.end method

.method public onCreate(Landroid/content/Context;Landroid/os/Handler;)V
    .locals 3
    .parameter "context"
    .parameter "handler"

    .prologue
    .line 139
    iput-object p2, p0, Lcom/melesta/payment/PaymentManager;->handler:Landroid/os/Handler;

    .line 140
    iget-object v2, p0, Lcom/melesta/payment/PaymentManager;->systemsList:Ljava/util/Map;

    invoke-interface {v2}, Ljava/util/Map;->values()Ljava/util/Collection;

    move-result-object v2

    invoke-interface {v2}, Ljava/util/Collection;->iterator()Ljava/util/Iterator;

    move-result-object v0

    .local v0, i$:Ljava/util/Iterator;
    :goto_0
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v2

    if-eqz v2, :cond_0

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/melesta/payment/interfaces/ISystem;

    .line 141
    .local v1, sys:Lcom/melesta/payment/interfaces/ISystem;
    invoke-interface {v1, p1, p2}, Lcom/melesta/payment/interfaces/ISystem;->onCreate(Landroid/content/Context;Landroid/os/Handler;)V

    goto :goto_0

    .line 142
    .end local v1           #sys:Lcom/melesta/payment/interfaces/ISystem;
    :cond_0
    return-void
.end method

.method public onDestroy(Landroid/content/Context;Landroid/os/Handler;)V
    .locals 3
    .parameter "context"
    .parameter "handler"

    .prologue
    .line 146
    iget-object v2, p0, Lcom/melesta/payment/PaymentManager;->systemsList:Ljava/util/Map;

    invoke-interface {v2}, Ljava/util/Map;->values()Ljava/util/Collection;

    move-result-object v2

    invoke-interface {v2}, Ljava/util/Collection;->iterator()Ljava/util/Iterator;

    move-result-object v0

    .local v0, i$:Ljava/util/Iterator;
    :goto_0
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v2

    if-eqz v2, :cond_0

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/melesta/payment/interfaces/ISystem;

    .line 147
    .local v1, sys:Lcom/melesta/payment/interfaces/ISystem;
    invoke-interface {v1, p1, p2}, Lcom/melesta/payment/interfaces/ISystem;->onDestroy(Landroid/content/Context;Landroid/os/Handler;)V

    goto :goto_0

    .line 148
    .end local v1           #sys:Lcom/melesta/payment/interfaces/ISystem;
    :cond_0
    return-void
.end method

.method public onPause(Landroid/content/Context;Landroid/os/Handler;)V
    .locals 3
    .parameter "context"
    .parameter "handler"

    .prologue
    .line 152
    iget-object v2, p0, Lcom/melesta/payment/PaymentManager;->systemsList:Ljava/util/Map;

    invoke-interface {v2}, Ljava/util/Map;->values()Ljava/util/Collection;

    move-result-object v2

    invoke-interface {v2}, Ljava/util/Collection;->iterator()Ljava/util/Iterator;

    move-result-object v0

    .local v0, i$:Ljava/util/Iterator;
    :goto_0
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v2

    if-eqz v2, :cond_0

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/melesta/payment/interfaces/ISystem;

    .line 153
    .local v1, sys:Lcom/melesta/payment/interfaces/ISystem;
    invoke-interface {v1, p1, p2}, Lcom/melesta/payment/interfaces/ISystem;->onPause(Landroid/content/Context;Landroid/os/Handler;)V

    goto :goto_0

    .line 154
    .end local v1           #sys:Lcom/melesta/payment/interfaces/ISystem;
    :cond_0
    return-void
.end method

.method public onResume(Landroid/content/Context;Landroid/os/Handler;)V
    .locals 3
    .parameter "context"
    .parameter "handler"

    .prologue
    .line 158
    iget-object v2, p0, Lcom/melesta/payment/PaymentManager;->systemsList:Ljava/util/Map;

    invoke-interface {v2}, Ljava/util/Map;->values()Ljava/util/Collection;

    move-result-object v2

    invoke-interface {v2}, Ljava/util/Collection;->iterator()Ljava/util/Iterator;

    move-result-object v0

    .local v0, i$:Ljava/util/Iterator;
    :goto_0
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v2

    if-eqz v2, :cond_0

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/melesta/payment/interfaces/ISystem;

    .line 159
    .local v1, sys:Lcom/melesta/payment/interfaces/ISystem;
    invoke-interface {v1, p1, p2}, Lcom/melesta/payment/interfaces/ISystem;->onResume(Landroid/content/Context;Landroid/os/Handler;)V

    goto :goto_0

    .line 160
    .end local v1           #sys:Lcom/melesta/payment/interfaces/ISystem;
    :cond_0
    return-void
.end method

.method public onStart(Landroid/content/Context;Landroid/os/Handler;)V
    .locals 3
    .parameter "context"
    .parameter "handler"

    .prologue
    .line 164
    iget-object v2, p0, Lcom/melesta/payment/PaymentManager;->systemsList:Ljava/util/Map;

    invoke-interface {v2}, Ljava/util/Map;->values()Ljava/util/Collection;

    move-result-object v2

    invoke-interface {v2}, Ljava/util/Collection;->iterator()Ljava/util/Iterator;

    move-result-object v0

    .local v0, i$:Ljava/util/Iterator;
    :goto_0
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v2

    if-eqz v2, :cond_0

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/melesta/payment/interfaces/ISystem;

    .line 165
    .local v1, sys:Lcom/melesta/payment/interfaces/ISystem;
    invoke-interface {v1, p1, p2}, Lcom/melesta/payment/interfaces/ISystem;->onStart(Landroid/content/Context;Landroid/os/Handler;)V

    goto :goto_0

    .line 166
    .end local v1           #sys:Lcom/melesta/payment/interfaces/ISystem;
    :cond_0
    return-void
.end method

.method public onStop(Landroid/content/Context;Landroid/os/Handler;)V
    .locals 3
    .parameter "context"
    .parameter "handler"

    .prologue
    .line 170
    iget-object v2, p0, Lcom/melesta/payment/PaymentManager;->systemsList:Ljava/util/Map;

    invoke-interface {v2}, Ljava/util/Map;->values()Ljava/util/Collection;

    move-result-object v2

    invoke-interface {v2}, Ljava/util/Collection;->iterator()Ljava/util/Iterator;

    move-result-object v0

    .local v0, i$:Ljava/util/Iterator;
    :goto_0
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v2

    if-eqz v2, :cond_0

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/melesta/payment/interfaces/ISystem;

    .line 171
    .local v1, sys:Lcom/melesta/payment/interfaces/ISystem;
    invoke-interface {v1, p1, p2}, Lcom/melesta/payment/interfaces/ISystem;->onStop(Landroid/content/Context;Landroid/os/Handler;)V

    goto :goto_0

    .line 172
    .end local v1           #sys:Lcom/melesta/payment/interfaces/ISystem;
    :cond_0
    return-void
.end method

.method public postResponse(Lcom/melesta/payment/interfaces/IResponse;)V
    .locals 2
    .parameter "response"

    .prologue
    .line 176
    if-nez p1, :cond_0

    .line 181
    :goto_0
    return-void

    .line 178
    :cond_0
    iget-object v1, p0, Lcom/melesta/payment/PaymentManager;->responses:Ljava/util/Queue;

    monitor-enter v1

    .line 179
    :try_start_0
    iget-object v0, p0, Lcom/melesta/payment/PaymentManager;->responses:Ljava/util/Queue;

    invoke-interface {v0, p1}, Ljava/util/Queue;->add(Ljava/lang/Object;)Z

    .line 180
    monitor-exit v1

    goto :goto_0

    :catchall_0
    move-exception v0

    monitor-exit v1
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v0
.end method

.method public process()V
    .locals 4

    .prologue
    .line 184
    iget-object v3, p0, Lcom/melesta/payment/PaymentManager;->requests:Ljava/util/Queue;

    monitor-enter v3

    .line 185
    :try_start_0
    iget-object v2, p0, Lcom/melesta/payment/PaymentManager;->requests:Ljava/util/Queue;

    invoke-interface {v2}, Ljava/util/Queue;->poll()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/melesta/payment/interfaces/IRequest;

    .line 186
    .local v0, request:Lcom/melesta/payment/interfaces/IRequest;
    if-eqz v0, :cond_0

    .line 187
    iget-object v2, p0, Lcom/melesta/payment/PaymentManager;->activeRequests:Ljava/util/List;

    invoke-interface {v2, v0}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 188
    iget-object v2, p0, Lcom/melesta/payment/PaymentManager;->handler:Landroid/os/Handler;

    invoke-virtual {v2, v0}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z

    .line 190
    :cond_0
    monitor-exit v3
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 191
    iget-object v3, p0, Lcom/melesta/payment/PaymentManager;->responses:Ljava/util/Queue;

    monitor-enter v3

    .line 192
    :try_start_1
    iget-object v2, p0, Lcom/melesta/payment/PaymentManager;->responses:Ljava/util/Queue;

    invoke-interface {v2}, Ljava/util/Queue;->poll()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/melesta/payment/interfaces/IResponse;

    .line 193
    .local v1, response:Lcom/melesta/payment/interfaces/IResponse;
    if-eqz v1, :cond_1

    .line 194
    iget-object v2, p0, Lcom/melesta/payment/PaymentManager;->handler:Landroid/os/Handler;

    invoke-virtual {v2, v1}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z

    .line 195
    :cond_1
    monitor-exit v3
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_1

    .line 196
    return-void

    .line 190
    .end local v0           #request:Lcom/melesta/payment/interfaces/IRequest;
    .end local v1           #response:Lcom/melesta/payment/interfaces/IResponse;
    :catchall_0
    move-exception v2

    :try_start_2
    monitor-exit v3
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    throw v2

    .line 195
    .restart local v0       #request:Lcom/melesta/payment/interfaces/IRequest;
    :catchall_1
    move-exception v2

    :try_start_3
    monitor-exit v3
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_1

    throw v2
.end method

.method public purchaseProcessed(Lcom/melesta/payment/PaymentTransaction;)V
    .locals 4
    .parameter "pt"

    .prologue
    .line 275
    iget-object v2, p0, Lcom/melesta/payment/PaymentManager;->systemsList:Ljava/util/Map;

    invoke-interface {v2}, Ljava/util/Map;->values()Ljava/util/Collection;

    move-result-object v2

    invoke-interface {v2}, Ljava/util/Collection;->iterator()Ljava/util/Iterator;

    move-result-object v0

    .local v0, i$:Ljava/util/Iterator;
    :cond_0
    :goto_0
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v2

    if-eqz v2, :cond_1

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/melesta/payment/interfaces/ISystem;

    .line 276
    .local v1, sys:Lcom/melesta/payment/interfaces/ISystem;
    invoke-interface {v1}, Lcom/melesta/payment/interfaces/ISystem;->getName()Ljava/lang/String;

    move-result-object v2

    iget-object v3, p1, Lcom/melesta/payment/PaymentTransaction;->paymentSystem:Ljava/lang/String;

    invoke-virtual {v2, v3}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-eqz v2, :cond_0

    .line 277
    invoke-interface {v1, p1}, Lcom/melesta/payment/interfaces/ISystem;->purchaseProcessed(Lcom/melesta/payment/PaymentTransaction;)V

    goto :goto_0

    .line 279
    .end local v1           #sys:Lcom/melesta/payment/interfaces/ISystem;
    :cond_1
    return-void
.end method

.method public removeActiveRequest(Lcom/melesta/payment/interfaces/IRequest;)V
    .locals 1
    .parameter "request"

    .prologue
    .line 110
    iget-object v0, p0, Lcom/melesta/payment/PaymentManager;->activeRequests:Ljava/util/List;

    invoke-interface {v0, p1}, Ljava/util/List;->remove(Ljava/lang/Object;)Z

    .line 111
    return-void
.end method
